<?php

namespace Home\Controller;

class IndexController extends HomeCoreController {
	
    public function index(){
		
		$this->display();
    
	}
	
	public function main(){
		
		$this->display();
    
	}
	
	public function cache(){
		
		header("Content-type:text/html; charset=utf-8");
		
		$dirs = array('./Runtime/');
		
		@mkdir('Runtime', 0777, true);
		
		foreach($dirs as $value){
			
			$this->rmdirr($value);
			
		}
		
		echo json_encode(array('info'=>'系统缓存清除成功', 'status'=>'y'));
		
	}
	
	public function rmdirr($dirname){
		
		if(!file_exists($dirname)){
			
			return false;
			
		}
		
		if(is_file($dirname) || is_link($dirname)){
			
			return unlink($dirname);
						
		}
		
		$dir = dir($dirname);
		
		if($dir) {
			
			while(false !== $entry = $dir->read()){
				
				if($entry =="." || $entry == ".."){
					
					continue;
					
				}
				
				$this->rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);	
								
			}
			
		}
		
		$dir->close();
		
		return rmdir($dirname);
		
	}
	
}